import 'package:flutter/material.dart';
import 'package:proj_shop/roots/weibo/pages/home/weibo_home_list_pager.dart';

class WeiBoHotPage extends StatefulWidget {
  @override
  _WeiBoHotPageState createState() => _WeiBoHotPageState();
}

class _WeiBoHotPageState extends State<WeiBoHotPage> {
  final List<String> _tabValues = ['推荐', '附近', '榜单', '明星', '搞笑', '社会', '测试'];
  TabController _controller;

  @override
  void initState() {
    _controller = TabController(
      length: _tabValues.length, //Tab页数量
      vsync: ScrollableState(), //动画效果的异步处理
    );

    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Column(
        children: [
          Container(
            height: 0.5,
            color: Color(0xffBECBC2),
          ),
          Stack(
            children: [
              Container(
                height: 45,
                // margin: EdgeInsets.only(top: 40.0),
                color: Color(0xffffffff),
                //  color:Colors.red,
                alignment: Alignment.center,
                child: TabBar(
                  tabs: buildTabs(),
                  isScrollable: true,
                  indicatorColor: Color(0xffffffff),
                  labelColor: Color(0xffFF3700),
                  unselectedLabelColor: Color(0xff666666),
                  labelStyle: TextStyle(
                    fontSize: 16.0,
                    fontWeight: FontWeight.w500,
                  ),
                  unselectedLabelStyle: TextStyle(fontSize: 16.0),
                  indicatorSize: TabBarIndicatorSize.label,
                  controller: _controller,
                ),
              ),
            ],
          ),
          Container(
            height: 0.5,
            color: Color(0xffBECBC2),
          ),
          Expanded(
            child: TabBarView(
              controller: _controller,
              children: <Widget>[
                WeiBoHomeListPager(mCatId: "1"),
                WeiBoHomeListPager(mCatId: "2"),
                WeiBoHomeListPager(mCatId: "3"),
                WeiBoHomeListPager(mCatId: "4"),
                WeiBoHomeListPager(mCatId: "5"),
                Center(
                  child: Text("暂无数据"),
                ),
                WeiBoHomeListPager(mCatId: "10"),
                //  WeiBoHomeListPager(),
              ],
            ),
          )
        ],
      ),
    );
  }

  List<Widget> buildTabs() {
    return [
      new Tab(
        text: _tabValues[0],
      ),
      new Tab(
        text: _tabValues[1],
      ),
      new Tab(
        text: _tabValues[2],
      ),
      new Tab(
        text: _tabValues[3],
      ),
      new Tab(
        text: _tabValues[4],
      ),
      new Tab(
        text: _tabValues[5],
      ),
      new Tab(
        text: _tabValues[6],
      ),
    ];
  }
}
